//
// Created by vista on 2017/12/8.
//

#ifndef P_P3_H
#define P_P3_H

#include <string>
#include <set>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;

class Solution {
public:
    int lengthOfLongestSubstring(string s) {

        int slen = s.length();

        if(slen == 0)
            return  0;

        int maxlen = 1;
        for (int i = 0; i < slen - 1; ++i) {
            char c = s[i];
            set<char> mset;
            mset.insert(c);
            for (int j = i+1; j < slen; ++j) {
                if(mset.find(s[j])!=mset.end()){
                    break;
                }else{
                    mset.insert(s[j]);
                }
            }

            if( mset.size()  > maxlen){
                maxlen = mset.size() ;
            }

        }

        return maxlen;

    }
};

#endif //P_P3_H
